package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.schedule.dtos.Task;
import com.zhentao.service.TaskInfoService;
import com.zhentao.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ScheduleClientApi implements com.zhentao.api.schedule.ScheduleClientApi {


    @Autowired
    private TaskInfoService taskInfoService;

    /**
     * 添加任务
     * @param task 任务对象
     * @return 任务id
     */
    @PostMapping("/api/v1/task/add")
    @Override
    public ResponseResult addTask(@RequestBody Task task) {
        return taskInfoService.addTask(task);
    }




    /**
     * 按照类型和优先级来拉取任务
     * @param type
     * @param priority
     * @return
     */
    @Override
    public ResponseResult poll(@PathVariable("type") int type) {
        return taskInfoService.submitCurrentPoll(type);
    }
}